package com.ddh.ddhsanguogame.controller;


import com.ddh.ddhsanguogame.common.BaseResponse;
import com.ddh.ddhsanguogame.common.DongResultUtils;
import com.ddh.ddhsanguogame.dto.CardUserRegisterDTO;
import com.ddh.ddhsanguogame.service.IUserService;
import com.ddh.ddhsanguogame.vo.CardUserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author
 * @since 2025-06-28
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户信息表")
public class UserController {

    @Autowired
    private IUserService userService;

    /**
     * 用户注册
     */
    @PostMapping("/register")
    @ApiOperation("用户注册")
    public BaseResponse<Boolean> register(@RequestBody CardUserRegisterDTO cardUserRegisterDTO) {
        boolean register = userService.register(cardUserRegisterDTO);
        return DongResultUtils.success(register);
    }

    /**
     * 用户登录
     */
    @PostMapping("/login")
    @ApiOperation("用户登录")
    public BaseResponse<CardUserLoginVO> login(@RequestBody CardUserRegisterDTO cardUserRegisterDTO) {
        CardUserLoginVO cardUserLoginVO = userService.login(cardUserRegisterDTO);
        return DongResultUtils.success(cardUserLoginVO);
    }

}
